#include <algorithm>
#include <iostream>
#include <string.h>
// #include "reopen"
using namespace std;
#define SIZE 6

int dp(int *a, int n) {
  int b[SIZE];
  for (int i = 0; i <= n; i++) {
    b[i] = a[i];
  }
  int ans = -1000;
  for (int i = n - 1; i >= 0; i--) {
    b[i] = max(b[i], b[i] + b[i + 1]);
    ans = max(ans, b[i]);
  }
  return ans;
}

int main(void) {
  //    reopen("1768");
  int a[SIZE][SIZE];
  int b[SIZE];
  int n;
  int maxMartix = -1000;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  for (int k = 0; k < n; k++) {
    memset(b, 0, sizeof(b));
    for (int i = k; i < n; i++) {

      for (int j = 0; j < n; j++) {
        b[j] += a[i][j];
      }
      maxMartix = max(maxMartix, dp(b, n));
    }
  }
  cout << maxMartix;
  return 0;
}